<!--
* description: 责任人弹出框（含输入框）
* author: zouzx
* createdDate: 2019-10-10
-->
<template>
  <section class="carTypeConfig">
    <el-col :span="span" v-show="showow">
      <lableName    
      :style="span==12?'width:14%':''" 
      :validrule="validrule"   
        :curLabelName="curLabelName"
        :isShowLabel="isShowLabel"
        :isRequire="isRequire"
      ></lableName>
      <el-input
        :style="setInputWidth(span)"
        placeholder="请选择"
        v-model="modelText"
        :disabled="disabled"
        size="small"
        suffix-icon="el-icon-menu"
        @clear="clearCode"
        clearable
        @blur="sendCode"
        @focus="getFocusCode"
      ></el-input>
      <validateFormate
        :curLabelName="curLabelName"
        :validrule="validrule"
      ></validateFormate>
    </el-col>
    <crmDutyPeople
      :popupsVisible="curPopupsVisible"
      :codeField="codeField"
      :textField="textField"
      :comType="comType"
      :valueObject="curValueObject"
      :popupsKey="popupsKey"
      :code="modelCode"
      :text="modelText"
      :key="curPopupsKey"
      :isMul="isMul"
      @changeCode="getComponentCode1"
    ></crmDutyPeople>
  </section>
</template>
<script>
import { searchInputMixins } from "@/components/mixins/searchInputMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
// import lableName from "@/components/lableName";
import crmDutyPeople from "./crmDutyPeople";
// import validateFormate from "@/components/validateFormate";
export default {
  // 组件混入对象
  mixins: [searchInputMixins, valueObjectMixins],
  components: {
    crmDutyPeople,
    lableName: () => import("@/components/lableName"), //标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate"), //校验提示样式组件
  },
  props:{
    show:{
      type:Boolean,
      default:true
    }
  },
  data() {
    return {
      showow:this.show,
      curLabelName: this.labelName === "" ? "责任人" : this.labelName,
      curValueObject: {
        isEnable:"1",
        positionCode:"VE0001",
      }
    };
  },
  mounted(){
    var parent = this.$utils.getHasFormFieldParentComponent(this);
    //回显
    this.modelText = parent.formField.dutyPersonName;
    
  },
  methods: {
    onShow() {
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      if (
        parent.formField &&
        parent.formField.serverType &&
        parent.formField.serverType !== ""
      ) {
        //赋值
        this.curValueObject.serverType = parent.formField.serverType;
        this.curPopupsKey = this.codeField + this.$utils.generateId();
      }
    },
    //传递网格列数据
    getComponentCode1(code,text,codeField,comType,popupsKey,textField,otherField,selectData) {
      this.getComponentCode(code,text,codeField,comType,popupsKey,textField,otherField,selectData);
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      let results = selectData[0];
      for (let key in parent.formField) {
        if (results.hasOwnProperty(key)) {
          parent.formField[key] = results[key];
        }
      }
      this.$emit("emitCode", selectData);
    },
    setInputWidth(span) {
      switch (span) {
        case 6:
          return "";
        case 12:
          return "width:85%;line-height: 38px;";
      }
    }
  }
};
</script>
